{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# using MATPLOTLIB\n",
    "# Python code to reading an image using OpenCV \n",
    "import cv2 \n",
    "import numpy as np \n",
    "import matplotlib.pyplot as plt \n",
    "  \n",
    "img = cv2.imread('foggy-5.jpg',  \n",
    "                  cv2.IMREAD_GRAYSCALE) \n",
    "  \n",
    "cv2.imshow('image', img) \n",
    "cv2.waitKey(0) \n",
    "cv2.destoryAllWindows() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# using NUMPY\n",
    "# Python code to reading an image using OpenCV \n",
    "import numpy as np \n",
    "import cv2 \n",
    "  \n",
    "# You can give path to the \n",
    "# image as first argument \n",
    "img = cv2.imread('foggy-5.jpg', 0) \n",
    "  \n",
    "# will show the image in a window \n",
    "cv2.imshow('image', img) \n",
    "k = cv2.waitKey(0) & 0xFF\n",
    "  \n",
    "# wait for ESC key to exit \n",
    "if k == 27:  \n",
    "    cv2.destroyAllWindows() \n",
    "      \n",
    "# wait for 's' key to save and exit \n",
    "elif k == ord('s'):  \n",
    "    cv2.imwrite('messigray.png',img) \n",
    "    cv2.destroyAllWindows() "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
